package com.hb.trade.api.im.chat.controller;

import com.hb.trade.api.im.main.TradeSystemWebSocketSession;
import lombok.extern.slf4j.Slf4j;
import org.fzzn.core.model.msg.ResponseDto;
import org.fzzn.core.model.websocket.SocketMessageEntity;
import org.fzzn.core.util.ResultUtil;
import org.fzzn.core.websocket.config.WebSocketSession;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ImClientController {

    @PostMapping("/im/info")
    public ResponseDto<SocketMessageEntity> imInfo(@RequestBody SocketMessageEntity messageEntity) {
        return ResultUtil.msg(true, messageEntity);
    }


    @PostMapping("/im/pushMessageCenter")
    public ResponseDto<SocketMessageEntity> pushMessageCenter(@RequestBody SocketMessageEntity messageEntity) {
        log.info(">>>>>>消息中心推送" + messageEntity);
        TradeSystemWebSocketSession.send(messageEntity);

        return ResultUtil.msg(true, messageEntity);
    }
}
